package com.baidu.service.impl;

import com.baidu.entity.OrderForm;
import com.baidu.entity.ShoppingCart;
import com.baidu.mapper.OrderFormMapper;
import com.baidu.mapper.ShoppingCartMapper;
import com.baidu.service.OrderFormService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @描述
 * @Author OrderFormServiceImpl
 * @Date 2019/4/18 15:31
 **/

@Service("orderFormService")
public class OrderFormServiceImpl implements OrderFormService {

@Resource
private OrderFormMapper orderFormMapper;




    /**
     * 添加订单信息
     * @param
     * @return
     */
    @Override
    public Integer insertOrderForm(String recipients, String sender, String companyname, String state,
                                   String street, String element, String city, String county, String postcode, String phone, String mailbox,
                                   String remark, String dataid) {

        //我要获取当前的日期
        Date date = new Date();
        //设置要获取到什么样的时间
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        //获取String类型的时间
        String createdate = sdf.format(date);

            OrderForm orderForm = new OrderForm();
            orderForm.setRecipients(recipients);
            orderForm.setSender(sender);
            orderForm.setCompanyname(companyname);
            orderForm.setState(state);
            orderForm.setStreet(street);
            orderForm.setElement(element);
            orderForm.setCity(city);
            orderForm.setCounty(county);
            orderForm.setPostcode(postcode);
            orderForm.setPhone(phone);
            orderForm.setMailbox(mailbox);
            orderForm.setRemark(remark);
            orderForm.setDataid(createdate);

        Integer i = orderFormMapper.insertOrderForm(orderForm);
        return i;



    }
    /**
     * 根据id查询订单信息
     * @param order_number
     * @return
     */
    @Override
    public OrderForm selectOrderFormById(Integer order_number) {
        OrderForm orderForm = orderFormMapper.selectOrderFormById(order_number);
        return orderForm;
    }



}
